// ObjectRegister.cpp: implementation of the ObjectRegister class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ObjectRegister.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace PDMS
{
	namespace PDMSDBIF
	{
		BEGIN_REGISTER_MAP( ObjectRegister, MultiRecordsDatabaseElement)
			REGISTER( _T("ObjRegister"), GET_REGISTER( DatabaseElementFactory, Design_VersionOne ) )
		END_REGISTER_MAP();
		ObjectRegister::ObjectRegister()
		{
			
		}
		
		ObjectRegister::~ObjectRegister()
		{
			
		}

		StdString ObjectRegister::GetOpenSQL( const StdString& strCondition )
		{
			StdString strTemp( _T("Select * from ObjRegister ") );
			if ( strCondition == ALLRECORD )
			{
				return strTemp;
			}

			return strTemp + _T("Where ") + strCondition;
		}
		
		StdString ObjectRegister::GetTableName()
		{
			return StdString( _T("ObjRegister") );
		}
		void ObjectRegister::SetData( RecordPtr_ ptr )
		{
			ASSERT( ptr != NULL );

			if ( ptr->IsIDModified() )
				m_ResPtr->SetLong( _T("ID"), ptr->GetID() );
			if ( ptr->IsClassNameModified() )
				m_ResPtr->SetString( _T("ClassName"), ptr->GetClassName() );
			if ( ptr->IsObjectNameModified() )
				m_ResPtr->SetString( _T("ObjName"), ptr->GetObjectName() );
		}
		
		long ObjectRegister::GetID()
		{
			ASSERT( m_ResPtr );
			return m_ResPtr->GetLong( _T("ID") );
		}
		
		StdString ObjectRegister::GetClassName()
		{
			ASSERT( m_ResPtr );
			return m_ResPtr->GetString( _T("ClassName") );
		}
		
		StdString ObjectRegister::GetObjectName()
		{
			ASSERT( m_ResPtr );
			return m_ResPtr->GetString( _T("ObjName") );
		}
	}
}
